package 预习;

public class 偶数的返回和 {
    public static void main(String[] args) {

        int[] arr = {29, 35, 38, 56, 21};

        int sum = getSum(arr);

        System.out.println("这个数组中偶数的和是" + sum);


    }

    public static int getSum(int[] arr) {
        int sum = 0;

        for (int i = 0; i < arr.length; i++) {

            if (arr[i] % 2 == 0) {
                sum += arr[i];
            }
        }
        return sum;
    }
}
